import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
const store = new Vuex.Store({
	state: {
		userInfo:localStorage.getItem('userInfo')?JSON.parse(localStorage.getItem('userInfo')):'',
		setLanguage: '',
	  department:localStorage.getItem('department')?JSON.parse(localStorage.getItem('department')):"",
		isHeader: false, //是否显示右上角
	},
	mutations: {
		CHANGE_HEADER(state, val) {
			state.isHeader = val;
		},
		ADD_USER(state, val) {
			state.userInfo = val;
      if(val){
        localStorage.setItem('userInfo', JSON.stringify(val))
      }

		},
		ADD_DEPARTMENT(state, val) {
			state.department = val;
      if(val){
        localStorage.setItem('department', JSON.stringify(val))
      }

		},
	},
	getters: {
		language: state => state.setLanguage
	}
})




export default store;
